﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gert3D
{
  /// <summary>
  /// Vertex is a simple vertex with a position, a normal and texture coordinates.
  /// </summary>
  public class Vertex
  {
    private Vector3 _position = new Vector3();
    private Vector3 _normal = null;
    private Vector3 _texCoord = null;

    /// <summary>
    /// Creates a new vertex at position (0,0,0), with normal (0,0,0) and texture coordinate (0,0,0).
    /// </summary>
    public Vertex()
    {
    }

    /// <summary>
    /// Creates a vertex at the given coordinates.
    /// </summary>
    /// <param name="x">The x component of the position.</param>
    /// <param name="y">The y component of the position.</param>
    /// <param name="z">The z component of the position.</param>
    public Vertex(double x, double y, double z)
    {
      _position.X = x;
      _position.Y = y;
      _position.Z = z;
    }

    /// <summary>
    /// Creates a vertex at the given coordinates and the given normal.
    /// </summary>
    /// <param name="x">The x component of the position.</param>
    /// <param name="y">The y component of the position.</param>
    /// <param name="z">The z component of the position.</param>
    /// <param name="nx">The x component of the normal.</param>
    /// <param name="ny">The y component of the normal.</param>
    /// <param name="nz">The z component of the normal.</param>
    public Vertex(double x, double y, double z, double nx, double ny, double nz)
    {
      _position.X = x;
      _position.Y = y;
      _position.Z = z;

      _normal._x = nx;
      _normal._y = ny;
      _normal._z = nz;
    }

    /// <summary>
    /// Creates a vertex at the given coordinates and the given normal.
    /// </summary>
    /// <param name="x">The x component of the position.</param>
    /// <param name="y">The y component of the position.</param>
    /// <param name="z">The z component of the position.</param>
    /// <param name="nx">The x component of the normal.</param>
    /// <param name="ny">The y component of the normal.</param>
    /// <param name="nz">The z component of the normal.</param>
    /// <param name="tu">The u value of the texture coordinates.</param>
    /// <param name="tv">The v value of the texture coordinates.</param>
    /// <param name="tw">The w value of the texture coordinates.</param>
    public Vertex(double x, double y, double z, double nx, double ny, double nz, double tu, double tv, double tw)
    {
      _position.X = x;
      _position.Y = y;
      _position.Z = z;

      _normal._x = nx;
      _normal._y = ny;
      _normal._z = nz;

      _texCoord.X = tu;
      _texCoord.Y = tv;
      _texCoord.Z = tw;
    }

    /// <summary>
    /// Gets or sets the position of the vertex.
    /// </summary>
    public Vector3 Position
    {
      get { return _position; }
      set { _position = value; }
    }

    /// <summary>
    /// Gets or sets the normal of the vertex.
    /// </summary>
    public Vector3 Normal
    {
      get { return _normal; }
      set { _normal = value; }
    }

    /// <summary>
    /// Gets or sets the texture coordinates of the vertex.
    /// The uvw values are mapped to xyz like x=u, y=v and z=w.
    /// </summary>
    public Vector3 TextureCoordinates
    {
      get { return _texCoord; }
      set { _texCoord = value; }
    }

  }
}
